﻿using System.Windows;

namespace ChessKit.Common
{
  public static class LogicalTreeExtensions
  {
    public static T FindLogicalParent<T>(this DependencyObject element)
      where T : class 
    {
      while (element != null)
      {
        if (element is T) return (T)(object)element;
        element = LogicalTreeHelper.GetParent(element);
      }
      return null;
    }
  }
}